package com.heima.wemedia.feign;

import com.heima.feign.wemedia.IWemediaClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmAutoScanService;
import com.heima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WemediaClient implements IWemediaClient {

    @Autowired
    private WmUserService wmUserService;
    @Autowired
    private WmAutoScanService wmAutoScanService;

    /**
     * 根据名字查看是否有媒体用户
     * @param name
     * @return
     */
    @PostMapping("/api/v1/wemedia/findWmUser")
    public WmUser findWmUser(String name) {
       return wmUserService.findWmUser(name);
    }

    @PostMapping("/api/v1/wemedia/createWmUser")
    public void createWmUser(@RequestBody WmUser newWmUser) {
        wmUserService.addWmUser(newWmUser);
    }

    @PostMapping("/api/v1/wemedia/autoscanComment")
    public ResponseResult autoscanComment(@RequestBody String comment) {
        return wmAutoScanService.scanComment(comment);
    }
}
